package com.yanfan.accessControl.service.impl;

import java.util.List;
import com.yanfan.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.accessControl.mapper.IbmsAccessFlowMapper;
import com.yanfan.accessControl.domain.IbmsAccessFlow;
import com.yanfan.accessControl.service.IIbmsAccessFlowService;

/**
 * 门禁流量每小时统计Service业务层处理
 *
 * @author genluo
 * @date 2024-09-27
 */
@Service
public class IbmsAccessFlowServiceImpl extends ServiceImpl<IbmsAccessFlowMapper, IbmsAccessFlow> implements IIbmsAccessFlowService {
    @Autowired
    private IbmsAccessFlowMapper ibmsAccessFlowMapper;


    /**
     * 查询门禁流量每小时统计列表
     *
     * @param ibmsAccessFlow 门禁流量每小时统计
     * @return 门禁流量每小时统计
     */
    @Override
    public List<IbmsAccessFlow> queryPageList(IbmsAccessFlow ibmsAccessFlow) {
        LambdaQueryWrapper<IbmsAccessFlow> lqw = buildQueryWrapper(ibmsAccessFlow);
        return ibmsAccessFlowMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return ibmsAccessFlowMapper.queryPageList(ibmsAccessFlow);
    }

    @Override
    public IbmsAccessFlow getCountFlow(String now) {
        return ibmsAccessFlowMapper.getCountFlow(now);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<IbmsAccessFlow> buildQueryWrapper(IbmsAccessFlow bo) {
        LambdaQueryWrapper<IbmsAccessFlow> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getInOutType()), IbmsAccessFlow::getInOutType, bo.getInOutType());
        lqw.eq(bo.getFlow() != null, IbmsAccessFlow::getFlow, bo.getFlow());
        lqw.eq(StringUtils.isNotBlank(bo.getCountTime()), IbmsAccessFlow::getCountTime, bo.getCountTime());
        lqw.eq(bo.getCountFlow() != null, IbmsAccessFlow::getCountFlow, bo.getCountFlow());
        return lqw;
    }




}
